/**
 * 矩阵行列分别循环左右移位
 */
class Solution {
public:
    bool areSimilar(const vector<vector<int>>& mat, int k) {
        auto tmp = mat;
        int n = mat.size();
        int m = mat[0].size();
        k %= m;
        for(int i=0;i<n;i+=2){
            rotate(tmp[i].begin(), tmp[i].begin()+m-k,tmp[i].end());
            if(i + 1 < n){
                rotate(tmp[i+1].begin(), tmp[i+1].begin()+k, tmp[i+1].end());
            }
        }
        for(int i=0;i<n;++i)for(int j=0;j<m;++j){
            if(mat[i][j] != tmp[i][j]) return false;
        }
        return true;
    }
};